package org.example.dp.bidimensional;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/13 20:57
 */
public class Solution118 {

    public static void main(String[] args) {
        Solution118 solution118 = new Solution118();
        System.out.println(solution118.generate(5));
    }

    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> result = new ArrayList<>();
        int[][] dp = new int[numRows][numRows];
        for (int i = 0; i < numRows; i++) {
            List<Integer> line = new ArrayList<>();
            for (int j = 0; j <= i; j++) {
                if(j==0 || i==j){
                    dp[i][j] = 1;
                }else{
                    dp[i][j] = dp[i-1][j] + dp[i-1][j-1];;
                }
                line.add(dp[i][j]);
            }
            result.add(line);
        }
        return result;
    }
}
